﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../../resources/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../../resources/lib/jquery/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="../../resources/lib/json2.js" type="text/javascript"></script>
    <script src="../../resources/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
    <script src="../../resources/lib/UsergroupDate.js" type="text/javascript"></script>
    <script src="../../resources/lib/PermissionData.js" type="text/javascript"></script>
    <script type="text/javascript">

        var PermissionList = PermissionData.Rows;
        //var sexData = [{ qx: 1, text: '男' }, { Sex: 2, text: '女'}];
        var SystemData = [{ System: 1, text: '禁用' }, { System: 2, text: '查看'},{System:3,text:'编辑'}];
        var SystemData1 = [{ System1: 1, text: '禁用' }, { System1: 2, text: '查看'},{System1:3,text:'编辑'}];
        var SystemData2 = [{ System2: 1, text: '禁用' }, { System2: 2, text: '查看'},{System2:3,text:'编辑'}];
        var SystemData3 = [{ System3: 1, text: '禁用' }, { System3: 2, text: '查看'},{System3:3,text:'编辑'}];
        var SystemData4 = [{ System4: 1, text: '禁用' }, { System4: 2, text: '查看'},{System4:3,text:'编辑'}];
        var SystemData5 = [{ System5: 1, text: '禁用' }, { System5: 2, text: '查看'},{System5:3,text:'编辑'}];
        var SystemData6 = [{ System6: 1, text: '禁用' }, { System6: 2, text: '查看'},{System6:3,text:'编辑'}];
        var SystemData7 = [{ System7: 1, text: '禁用' }, { System7: 2, text: '查看'},{System7:3,text:'编辑'}];
        $(f_initGrid);
        var manager, g;
        function f_initGrid()
        { 
           g =  manager = $("#maingrid").ligerGrid({
                columns: [
                { display: '角色名称', name: 'Name',width:100,
                    editor: { type: 'text'}
                },
                /*{ display: '对应权限', name: 'Permission', width: 120, isSort: false,
                    editor: { type: 'select', data: PermissionList, valueColumnName: 'Permission', displayColumnName: 'PermissionName' }, render: function (item)
                {
                    for (var i = 0; i < PermissionList.length; i++)
                    {
                        if (PermissionList[i]['Permission'] == item.Permission)
                            return PermissionList[i]['PermissionName']
                    }
                    return item.PermissionName;

                }
                },*/
                {
                    display:'权限项',columns:[
                    { display: '系统设置', width: 60, name: 'System',
                        editor: { type: 'select', data: SystemData, valueColumnName: 'System' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';

                        }
                    },
                    { display: '节假日设置', name: 'Holiday', width: 60,
                        editor: { type: 'select', data: SystemData1, valueColumnName: 'System1' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';
                        }
                    },
                    { display: '时间域设置', name: 'Time', width: 60,
                        editor: { type: 'select', data: SystemData2, valueColumnName: 'System2' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';
                        }
                    },
                    { display: '人组设置', name: 'People', width: 60,
                        editor: { type: 'select', data: SystemData3, valueColumnName: 'System3' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';
                        }
                    },
                    { display: '门组设置', name: 'Door', width: 60,
                        editor: { type: 'select', data: SystemData4, valueColumnName: 'System4' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';
                        }
                    },
                    { display: '规则设置', name: 'Role', width: 60,
                        editor: { type: 'select', data: SystemData5, valueColumnName: 'System5' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';
                        }
                    },
                    { display: '权限设置', name: 'Power', width: 60,
                        editor: { type: 'select', data: SystemData6, valueColumnName: 'System6' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';
                        }
                    },
                    { display: '区域设置', name: 'Area', width: 60,
                        editor: { type: 'select', data: SystemData7, valueColumnName: 'System7' },
                        render: function (item)
                        {
                            if (parseInt(item.System) == 1) return '禁用';
                            if (parseInt(item.System) == 2) return '查看';
                            if (parseInt(item.System) == 3) return '编辑';
                        }
                    }
                ]
                },
                { display: '操作', isSort: false, width: 100, render: function (rowdata, rowindex, value)
                {
                    var h = "";
                    if (!rowdata._editing)
                    {
                        h += "<a href='javascript:beginEdit(" + rowindex + ")'>修改</a> ";
                        h += "<a href='javascript:deleteRow(" + rowindex + ")'>删除</a> ";
                    }
                    else
                    {
                        h += "<a href='javascript:endEdit(" + rowindex + ")'>提交</a> ";
                        h += "<a href='javascript:cancelEdit(" + rowindex + ")'>取消</a> ";
                    }
                    return h;
                }
                }



                ],

                onSelectRow: function (rowdata, rowindex)
                {
                    $("#txtrowindex").val(rowindex);
                },
                enabledEdit: true, isScroll: false, checkbox:true,rownumbers:true,clickToEdit:false,
                data:UsergroupDate,
                width: '100%'
            });   
        }

        function beginEdit(rowid) {
            manager.beginEdit(rowid);
        }
        function cancelEdit(rowid) {
            manager.cancelEdit(rowid);
        }
        function endEdit(rowid)
        {
            manager.endEdit(rowid);
        }

        function deleteRow(rowid)
        {
            if (confirm('确定删除?'))
            {
                manager.deleteRow(rowid);
            }
        }
        var newrowid = 100;
        function addNewRow()
        {
            var row = manager.getSelectedRow();
            //参数1:rowdata(非必填)
            //参数2:插入的位置 Row Data 
            //参数3:之前或者之后(非必填)
            manager.addRow({ 
                DepartmentID: 3,
                DepartmentName: '销售部',
                RealName: "分为" + newrowid,
                ID: newrowid++,
                Sex : 1,
                Age : 25,
                IncomeDay: new Date(1306108800000),
                Phone : "2343434",
                Address: "wwrere4"
            }, row, document.getElementById("chkbefore").checked);
        } 
        function getSelected()
        { 
            var row = manager.getSelectedRow();
            if (!row) { alert('请选择行'); return; }
            alert(JSON.stringify(row));
        }
        function getData()
        { 
            var data = manager.getData();
            alert(JSON.stringify(data));
        } 
    </script>
</head>
<body  style="padding:10px">

<div class="l-clear"></div>

<a class="l-button" style="width:100px;float:left; margin-left:10px;" onclick="addNewRow()">添加权限组</a>

<div>

    是否之前：
    <input type="checkbox" id="chkbefore" />
</div>
<div id="maingrid" style="margin-top:20px"></div> <br />
<div style="display:none;">
    <!-- g data total ttt -->
</div>
</body>
</html>
